<div id='breadcrumb'>
  <%=  breadcrumb_for_category(@category)%>
</div>

<% if @brands && @brands.length > 1 %>
  <h4 class="brand_list_title">按品牌选择</h4>
  <ul class="category_brand_list">
    <% for b in @brands %>
      <li>
        <a href="/categories/<%= params[:id] %>?brand_id=<%= b.id %>">
          <%=h b.name%><span>|</span>
        </a>
      </li>
    <% end %>
  </ul>
<% end  %>

<% if @sub_category.size > 1 %>
  <div>
    <h4  class="brand_list_title">按类别选择</h4>
    <ul class="category_brand_list">
      <% for c in @sub_category %>
        <li><a href="/categories/<%=c.id%><%="?brand_id=#{params[:brand_id]}" if params[:brand_id]%>">
            <%="#{c.title}"%><span>|</span>
          </a></li>
      <%  end %>
    </ul>
  </div>
<% end  %>


<% if @products %>
  <ul id="product_list">
    <% for product in @products %>
      <%= render :partial =>'/products/product_li',:object=>product %>
    <% end %>
  </ul>
  <div id="pager">
    <%= will_paginate @products,:prev_label => '«上一页',:next_label => '下一页»' %>
  </div>
<%end%>


<% if admin? %>
  <div class="admin_toolbar">
    <span>
      <b>可用:</b>
      <%=format_boolean @category.active %>
    </span>
    <p>
      <%=form_tag("migrate_product")%>
      迁移商品至：
      <select id="new_category_id" name="new_category_id">
        <option value="">请选择...</option>
        <%=option_groups_from_collection_for_select(Category.parent_categories,
          :children,
          :title,
          :id,
          :title)%>
      </select>
      <%= submit_tag "迁移",:confirm =>'确定要迁移商品?'%>
      </form>

    </p>
    <br />
    <%= link_to '编辑', edit_category_path(@category),:class=>'action_edit' %> |
    <%= link_to '类别列表', categories_path,:class=>'action_list' %> |
    <a href="/products/new" class='action_add'>添加商品</a>
    <%  if @category.children.size > 0 %>
      |
      <a href="/categories/<%=@category.id%>/sort_sub_category" class='action_sort'>子类排序</a>
    <% end %>
    <%  if @category.products.size > 0 %>
      |
      <a href="/categories/sort_product/<%=@category.id%><%="?brand_id=#{params[:brand_id]}" if params[:brand_id] %>" class='action_sort'>商品排序</a>

      |
      <a href="/products/edit_price?category_id=<%=params[:id]%><%="&brand_id=#{params[:brand_id]}" if @brand%>" class='action_edit'>批量编辑价格</a>

    <% end %>
    <% if @brands %>
      |
      <a href="/categories/<%=@category.id%>/sort_brand" class='action_sort'>品牌排序</a>

    <%end%>
  </div>
<% end %>


<div class="category_list_break"></div>
